home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / Digital Money™ Dev Kit / DM Development / pascal / DMInterface.p
Encoding:
Text File  |  1995-04-08  |  3.9 KB  |  125 lines  |  [TEXT/PJMM]

  1.  
  2.  
  3. {        Digital Money Pascal Interface     }
  4. {                            courtesy of               }
  5. {                           John Mancino              }
  6. {               Decision Maker's Software     }
  7. {                mancino@decismkr.com         }
  8.  
  9. { Please address all questions first to Digital Money, Inc. }
  10. { last updated April 5, 1995 }
  11.  
  12.  
  13. {3/16/95 NOTE:  This interface has undergone moderate testing.  The data structures and code for calling DMM seem to be correct.}
  14. {                          The data returned by AutoPay has not been exhaustively checked but results should be identical to that obtained from}
  15. {                          using the C headers}
  16.  
  17.  
  18.  
  19.  
  20. unit DMInterface;
  21.  
  22. interface
  23.  
  24. uses
  25.     SANE;    {If your implementation supports 4 byte Reals, you can probably remove SANE and change the "Singles" to "Reals"}
  26.  
  27. type
  28.     purchaseItemType = record
  29.             quantity: integer;
  30.             name: array[1..40] of signedbyte;
  31.             prodCode: array[1..16] of signedbyte;
  32.             varCode: array[1..16] of signedbyte;
  33.             price: single;
  34.             maxPurchase: integer;
  35.             minPurchase: integer;
  36.             editable: integer;  {boolean interpretation}
  37.             shUSA: single;
  38.             shFOR: single;
  39.         end;
  40.  
  41.     catalogItemType = record
  42.             name: array[1..40] of signedbyte;
  43.             price: single;
  44.             maxPurchase: integer;
  45.             minPurchase: integer;
  46.             prodCode: array[1..16] of signedbyte;
  47.             shUSA: single;
  48.             shFOR: single;
  49.             numVarCodes: integer;
  50.             numPurchased: integer;
  51.             varCode1: array[1..16] of signedbyte;
  52.             varCode2: array[1..16] of signedbyte;
  53.             varCode3: array[1..16] of signedbyte;
  54.             varCode4: array[1..16] of signedbyte;
  55.             varCode5: array[1..16] of signedbyte;
  56.             varCode6: array[1..16] of signedbyte;
  57.             varCode7: array[1..16] of signedbyte;
  58.             varCode8: array[1..16] of signedbyte;
  59.         end;
  60.     catalogItemTypePtr = ^catalogItemType;
  61.  
  62.     digiMonBlock = record
  63.             userAborted: integer;  {boolean interpretation}
  64.             userChoseWhichOption: integer;
  65.             modemPaymentAccepted: integer;  {boolean interpretation}
  66.             userSuccessfullyTelUnlocked: integer;  {boolean interpretation}
  67.             userSuccessfullyMailUnlocked: integer;  {boolean interpretation}
  68.             modemPaymentIncludedReg: integer;  {boolean interpretation}
  69.             finalPurchaseAmount: single;
  70.             orderNumber: array[1..16] of signedbyte;
  71.             serialNumber: array[1..30] of signedbyte;
  72.             unlockCode: array[1..30] of signedbyte;
  73.             usersName: array[1..80] of signedbyte;
  74.             programName: array[1..30] of signedbyte;
  75.             programSource: array[1..20] of signedbyte;
  76.             encodeMeth: array[1..30] of signedbyte;
  77.             privateKey: array[1..30] of signedbyte;
  78.             programID: array[1..20] of signedbyte;
  79.             programPassword: array[1..20] of signedbyte;
  80.             returnSerialNum: integer;  {boolean interpretation}
  81.             areAdditionalItemsForSale: integer;  {boolean interpretation}
  82.             screenText: array[1..10] of ptr;
  83.             textSize: array[1..10] of integer;
  84.             textFont: array[1..10] of integer;
  85.             numItemsInCatalog: integer;
  86.             catalogItem: array[1..20] of catalogItemTypePtr;
  87.             numItemsPrepurchased: integer;
  88.             prepurchaseItem: array[1..6] of purchaseItemType;
  89.         end;
  90.     digiMonBlockPtr = ^digiMonBlock;
  91.  
  92. { The following function is meant to duplicate the C calling procedure presented in the manual.  Simply provide a pointer to the}
  93. { digiMonBlock record which you have already allocated and initialized according to the documentation}
  94.  
  95. function RunDM (theDMBlockPtr: digiMonBlockPtr): oserr;
  96.  
  97.  
  98. implementation
  99.  
  100.  
  101. function RunDMCR (theDMBlockPtr: digiMonBlockPtr; theCodePtr: ptr): oserr;
  102. inline
  103.     $205F,     { Move.l (SP)+,A0}
  104.     $4E90;    { JSR(A0) }
  105.  
  106. function RunDM (theDMBlockPtr: digiMonBlockPtr): oserr;
  107.     var
  108.         theCRHandle: handle;
  109.         theLoadErr: oserr;
  110.     begin
  111.         theCRHandle := GetResource('CODE', 60);
  112.         theLoadErr := ResError;
  113.         if (theLoadErr = noErr) & (theCRHandle <> nil) then
  114.             begin
  115.                 MoveHHi(theCRHandle);
  116.                 HLock(theCRHandle);
  117.                 RunDM := RunDMCR(theDMBlockPtr, theCRHandle^);
  118.                 HUnlock(theCRHandle);
  119.                 ReleaseResource(theCRHandle);
  120.             end
  121.         else
  122.             RunDM := resNotFound;
  123.     end;
  124.  
  125. end.